package baseFx.common.config.apollo;

import com.ctrip.framework.apollo.core.enums.Env;
import com.ctrip.framework.apollo.internals.DefaultMetaServerProvider;

import java.util.HashMap;
import java.util.Map;

public class ApolloMetaServerProvider extends DefaultMetaServerProvider {
    public final static Map<Env, String> envAddress = new HashMap<>();

    @Override
    public String getMetaServerAddress(Env targetEnv) {
        if (envAddress.size() == 1) {
            return envAddress.values().iterator().next();
        }
        if (envAddress.containsKey(targetEnv)) {
            return envAddress.get(targetEnv);
        }
        return super.getMetaServerAddress(targetEnv);
    }
}
